<% 
const userConfig = require('../config/userConfig');
const configKeys = Object.keys(userConfig.appConfig);
const config = userConfig.appConfig[htmlWebpackPlugin.options.chunks];
%>
<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<title>
		<%=htmlWebpackPlugin.options.title%>
	</title>
	<%if(htmlWebpackPlugin.options.chunks.length>0) {%>
	<%for (var i = 0; i < config.requires.length; i++) {%>
	<script src="<%=config.requires[i]%>"></script>
	<%}%>
	<script>window.GM_Resource={};</script>
	<%for (var i = 0; i < config.resources.length; i++) {%>
	<script>eval('window.GM_Resource["<%=config.resources[i].key%>"]="<%=config.resources[i].val%>";')</script>
	<%}%>
	<script src="<%=userConfig.baseUrl+htmlWebpackPlugin.options.chunks%>/userScript.js"></script>
	<%} else {%>
	<script>
		(function () {
            //加载layui
            var layuiLink = document.createElement('link');
            layuiLink.rel = 'stylesheet';
            layuiLink.href = '<%=userConfig.layuiCssPath%>';
            document.head.appendChild(layuiLink);
            var layuiScript = document.createElement('script');
            layuiScript.src = '<%=userConfig.layuiJsPath%>';
            layuiScript.onload = function () {
                var layuiBasePath = `/res/gm-layui/`;
                layui.config({
                    dir: '<%=userConfig.baseUrl%>' + layuiBasePath,
                    version: false,
                    debug: false,
                    base: layuiBasePath
                });
                layui.use(['util', 'layer'], () => {
                    const util = layui.util;
                    const $ = layui.jquery;
                    const layer = layui.layer;
                    layer.msg('layui 初始化完毕');
                });
            }
            document.head.appendChild(layuiScript);
        })();
	</script>
	<%}%>
</head>

<body class="layui-layout-body">
	<div class="layui-layout layui-layout-admin">
		<div class="layui-header">
			<div class="layui-logo">
				<%=htmlWebpackPlugin.options.title%>
			</div>
			<!-- 头部区域（可配合layui已有的水平导航） -->
			<!-- <ul class="layui-nav layui-layout-left">
  <li class="layui-nav-item"><a href="">控制台</a></li>
  <li class="layui-nav-item"><a href="">商品管理</a></li>
  <li class="layui-nav-item"><a href="">用户</a></li>
  <li class="layui-nav-item">
	<a href="javascript:;">其它系统</a>
	<dl class="layui-nav-child">
	  <dd><a href="">邮件管理</a></dd>
	  <dd><a href="">消息管理</a></dd>
	  <dd><a href="">授权管理</a></dd>
	</dl>
  </li>
</ul>
<ul class="layui-nav layui-layout-right">
  <li class="layui-nav-item">
	<a href="javascript:;">
	  <img src="http://t.cn/RCzsdCq" class="layui-nav-img">
	  贤心
	</a>
	<dl class="layui-nav-child">
	  <dd><a href="">基本资料</a></dd>
	  <dd><a href="">安全设置</a></dd>
	</dl>
  </li>
  <li class="layui-nav-item"><a href="">退了</a></li>
</ul> -->
		</div>

		<div class="layui-side layui-bg-black">
			<div class="layui-side-scroll">
				<!-- 左侧导航区域（可配合layui已有的垂直导航） -->
				<ul class="layui-nav layui-nav-tree" lay-filter="test">
					<li class="layui-nav-item layui-nav-itemed">
						<a class="" href="/index.html">UserScripts</a>
						<dl class="layui-nav-child">
							<%for (var i = 0; i < configKeys.length; i++) {%>
								<dd>
									<a href="<%=userConfig.baseUrl+configKeys[i]+'/index.html'%>" target="_blank">
										<%=configKeys[i]%>
									</a>
								</dd>
								<%}%>
						</dl>
					</li>
					<!-- <li class="layui-nav-item">
	  <a href="javascript:;">解决方案</a>
	  <dl class="layui-nav-child">
		<dd><a href="javascript:;">列表一</a></dd>
		<dd><a href="javascript:;">列表二</a></dd>
	  </dl>
	</li>
	<li class="layui-nav-item"><a href="">云市场</a></li>
	<li class="layui-nav-item"><a href="">发布商品</a></li> -->
				</ul>
			</div>
		</div>

		<div class="layui-body">
			<!-- 内容主体区域 -->
			<div style="padding: 15px;">资源内容展示</div>
		</div>

		<div class="layui-footer">
			<!-- 底部固定区域 -->
			底部固定区域
		</div>
	</div>
</body>

</html>